package com.founder.devwork.persistence.gateway.gitlab.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class CommitPkDTO {

    private Long repoId;

    @JsonProperty("id")
    private String sha;

    /**
     * 判断两个CommitPkDTO是否相等, 只比较sha
     *
     * @param obj 要比较的CommitPkDTO
     * @return 如果相等，返回true；否则返回false
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        CommitPkDTO other = (CommitPkDTO) obj;
        return Objects.equals(sha, other.sha);
    }

    /**
     * 计算CommitPkDTO的哈希值, 只计算sha
     *
     * @return 哈希值
     */
    @Override
    public int hashCode() {
        return Objects.hash(sha);
    }
}
